package com.spring.gateway;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class DefaultController {

	
	@RequestMapping("/defaultfallback")
    public Map<String,String> defaultfallback(){
        System.err.println("降本机级操作...");
        Map<String,String> map = new HashMap<>();
        map.put("resultCode","fail");
        map.put("resultMessage","服务异常");
        map.put("resultObj","null");
        
        //HttpServerletRequest 装请求信息类
        //HttpServerletRespionse 装相应信息的类
       // Cookie cookie=new Cookie("sessionId","CookieTestInfo");
       // response.addCookie(cookie);
        
        return map;
    }
	
	@RequestMapping(value = "/setCookies",method = RequestMethod.GET)
    public  String setCookies(HttpServletResponse response){
        //HttpServerletRequest 装请求信息类
        //HttpServerletRespionse 装相应信息的类
        Cookie cookie=new Cookie("sessionId","CookieTestInfo");
        response.addCookie(cookie);
        return "获得cookies信息成功";
    }
}
